<include file="Public/min-header"/>
<div class="wrapper">
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
    
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 批量导入商品</h3>
                </div>
                <div class="panel-body">
                    <!--表单数据-->
                    <form method="post" id="addEditBrandForm">             
                        <!--通用信息-->
                    <div class="tab-content">                 	  
                        <div class="tab-pane active" >
                            <div class="box-body">
                                <div class="form-group">
                                  <label for="batch">文件上传</label>
                                  <input type="file" id="batch" >

                                  <p class="help-block">请按规定模板上传</p>
                                  <a class="help-block" style="color: #ff0000" href="https://xjt.zczmer.com/Public/导入模板.xlsx">点击下载模板</a>
                                </div>
                              </div>
                        </div>                           
                    </div>              
                    <div class="box-footer">
                        <button  type="button" onclick="ajax_action()" class="btn btn-primary">提交</button>
                      </div>
			    </form><!--表单数据-->
                </div>
            </div>
        </div>    <!-- /.content -->
    </section>
</div>
<script>
    function ajax_action(){
                var data = new FormData();
                data.append("file", $('#batch')[0].files[0]);
                layer.load();
               $.ajax({
                   url: '{:U("Seller/goods/batch_add")}',
                   data: data,
                   type: "POST",
                   processData: false,//用于对data参数进行序列化处理 这里必须false
                   contentType: false, //必须
                   cache: false, //上传文件不需要缓存
                   success: function (result) {
                       layer.closeAll('loading');
                       layer.msg('上传完成', {icon: 1,time: 1000}, function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);//关闭弹出层
                        });
                   },
               })
    }
</script>
</body>
</html>